﻿using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Markup;
using Kotonoha.Server.Settings;

namespace Kotonoha.Server.UI.Converters {
    [MarkupExtensionReturnType(typeof(Setting))]
    class SettingsSourceExtension : MarkupExtension {
        public override object ProvideValue(IServiceProvider serviceProvider) {
            // Check for design mode. 
            if ((bool)(DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue)) {
                return null;
            }
            return SettingsManager.Acquire(Name);
        }

        public string Name { get; set;}
    }
}